package com.ruoyi.cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.cms.domain.Variable;
import com.ruoyi.cms.mapper.VariableMapper;
import com.ruoyi.cms.service.VariableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VariableServiceImpl implements VariableService {

	@Autowired
	private VariableMapper variableMapper;



	@Override
	public void add(Variable variable) {
		variableMapper.insert(variable);
	}

	@Override
	public Variable queryVariableId(String id) {
		return variableMapper.selectById(id);
	}

	@Override
	public void updateVariable(Variable variable) {
		variableMapper.updateById(variable);
	}

	@Override
	public int deleteVariable(String id) {
		return variableMapper.deleteById(id);
	}

	@Override
	public Variable queryVariableByName(String name) {
		return variableMapper.queryVariableByName(name);
	}

    @Override
    public List<Variable> selectVariableList() {
        LambdaQueryWrapper<Variable> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(Variable::getId);
        return variableMapper.selectVoList(wrapper);
    }

}
